package com.example.rdcproject.ving.notes.view.User;

import com.example.rdcproject.ving.notes.dao.AnnouncementBoardDao;
import com.example.rdcproject.ving.notes.dao.UserDao;
import com.example.rdcproject.ving.notes.entity.Announcement;
import com.example.rdcproject.ving.notes.util.LearnWordUtil;


import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.time.LocalDateTime;


public class UserInteractionView extends JFrame{

     AnnouncementBoardDao announcementBoardDao = new AnnouncementBoardDao();

     public UserInteractionView(){
         JFrame frame = new JFrame("功能主页面");
         JPanel panel = new JPanel();

         Announcement announcement = new Announcement();
//         announcement = announcementBoardDao.addAnnouncement();
//
//         String title = announcement.getTitle();
//         String content = announcement.getContent();
//         LocalDateTime publishTime =announcement.getPublishTime();
//
//         JOptionPane.showMessageDialog(null, content, title + "（" + publishTime + "）", JOptionPane.INFORMATION_MESSAGE);
         frame.add(panel);

         frame.setSize(500, 500);

         // 设置窗口相对指定主键位置
         frame.setLocationRelativeTo(null);

         // 设置窗口关闭操作
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


         //添加按钮
         JButton learnButton = new JButton("学习单词");
         learnButton.setBounds(80,80,60,60);
         panel.add(learnButton);
         JButton personnalButton = new JButton("修改个人信息");
         personnalButton.setBounds(250,80,60,60);
         panel.add(personnalButton);
         JButton searchButton = new JButton("查询他人");
         searchButton.setBounds(80,250,60,60);
         panel.add(searchButton);
         JButton rankButton = new JButton("排行榜");
         rankButton.setBounds(250,250,60,60);
         panel.add(rankButton);
         JButton addButton = new JButton("添加词书");
         addButton.setBounds(80,350,60,60);
         panel.add(addButton);

         learnButton.addActionListener(new ActionListener() {
             @Override
             public  void actionPerformed(ActionEvent e) {
                 LearnWordView learnWordView = new LearnWordView();
                  learnWordView.setVisible(true);

             }
         });

         searchButton.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
                 SelectOneView searchView = new SelectOneView();
                 searchView.setVisible(true);
             }
         });

         personnalButton.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e){
               PersonnalInfoView personnalInfoView =  new PersonnalInfoView();
               personnalInfoView.setVisible(true);
            }
         });

         rankButton.addActionListener(new ActionListener(){
             @Override
             public void actionPerformed(ActionEvent e){
                RankView rankView = new RankView();
                rankView.setVisible(true);
             }
         });

         addButton.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e){
                 LearnWordUtil learnWordUtil = LearnWordUtil.getInstance();
                 learnWordUtil.createWordList();
             }
         });
         frame.pack();
         frame.setVisible(true);

     }

}
